home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / share / pyshared / ibus / observedpath.py < prev    next >
Text File  |  2009-11-05  |  2KB  |  64 lines

  1. # vim:set et sts=4 sw=4:
  2. #
  3. # ibus - The Input Bus
  4. #
  5. # Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
  6. #
  7. # This library is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2 of the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with this program; if not, write to the
  19. # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  20. # Boston, MA  02111-1307  USA
  21.  
  22. __all__ = (
  23.         "ObservedPath",
  24.     )
  25.  
  26. import dbus
  27. from exception import IBusException
  28. from serializable import *
  29.  
  30. class ObservedPath(Serializable):
  31.     __gtype_name__ = "PYIBusObservedPath"
  32.     __NAME__ = "IBusObservedPath"
  33.     def __init__ (self, path="", mtime=0):
  34.         super(ObservedPath, self).__init__()
  35.         self.__path = path
  36.         self.__mtime = mtime
  37.  
  38.     def get_path(self):
  39.         return self.__path
  40.  
  41.     def get_mtime(self):
  42.         return self.__mtime
  43.  
  44.     path        = property(get_path)
  45.     mtime       = property(get_mtime)
  46.  
  47.     def serialize(self, struct):
  48.         super(ObservedPath, self).serialize(struct)
  49.         struct.append (dbus.String(self.__path))
  50.         struct.append (dbus.Int64(self.__mtime))
  51.  
  52.     def deserialize(self, struct):
  53.         super(ObservedPath, self).deserialize(struct)
  54.         self.__path = struct.pop(0)
  55.         self.__mtime = struct.pop(0)
  56.  
  57. def test():
  58.     op = ObservedPath("/tmp", 111)
  59.     value = serialize_object(op)
  60.     op=  deserialize_object(value)
  61.  
  62. if __name__ == "__main__":
  63.     test()
  64.